package com.example.voucher.common;

public enum StatusEnum {
    Drafted("D", "底稿"), Approved("A", "批准");

    private String code;
    private String desc;

    private StatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static StatusEnum getByCode(String code) {
        for (StatusEnum e : StatusEnum.values()) {
            if (e.code.equals(code)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        for (StatusEnum e : StatusEnum.values()) {
            if (e.code.equals(code)) {
                return e.getDesc();
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
